<template>
  <NewArticle :topic="topic"></NewArticle>
</template>

<script setup lang="ts">
import NewArticle from './index.vue';
import { fetchTopic } from '@/server'

//router
const router = useRouter()
const route = useRoute()
//帖子
const topic = ref()



onMounted(() => {
  if (route.params.id){
    //获取帖子
    fetchTopic(route.params.id as string, () => true).then( (data) => {
      topic.value = data   
      
    }).catch(err => {
      if (err) {
        router.replace("/404")
      }
    })
  }
})



</script>

<style scoped>

</style>
<route lang="yaml">
meta:
  layout: home
</route>